// interface C2<T> {
//   compare(r:T):number
// }

// class c2 implements C2<c1> {
//   compare(r: c1): number {
//     throw new Error("Method not implemented.");
//   }

// }
// class c1 implements C2<c2> {
//   compare(r: c2): number {
//     throw new Error("Method not implemented.");
//   }

// }
// class ImplC2 implements Compareable {
//   compare(right: this): number {
//     throw new Error("Method not implemented.");
//   }
  
// }
// let c_1 = new ImplC()
// let c_2 = new ImplC2()





interface Compareable {
  compare(right: this): number;
}
class ImplC implements Compareable {
  compare(right: this): number {
    return this.num - right.num
  }
  num: number;

}

function bubble_sort<T extends Compareable>(array: Array<T>):Array<T> {
  let finals = array.sort((a,b) => {
    let ret = a.compare(b)
    return ret
  })
  return finals
}



//interface 的this === Self